home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / networking / misc / epatsch10.lha / EPatsch1.0.rexx
Encoding:
OS/2 REXX Batch file  |  1994-08-30  |  2.9 KB  |  107 lines

  1. /*
  2.  * $VER: EPatsch 1.0 (30.6.94)
  3.  *
  4.  * patch to make OpenFromLock() work via Envoy
  5.  *
  6.  * (C) 1994 by Bernhard Möllemann
  7.  *
  8.  * This patch applies only to filesystem.service
  9.  * "fs 40.11 (6.9.93)" or "fs 40.12 (19.10.93)"
  10.  * which was distributed with Envoy 1.0 and 1.6/1.65
  11.  *
  12.  * The filesystem.service from Envoy has a bug: it doesn't initialize
  13.  * dp_Arg1 when sending ACTION_FH_FROM_LOCK to the FS on the remote system,
  14.  * conjuring enforcer hits or even worse things from the FileSystem.
  15.  *
  16.  * Inspecting the code (following a Hint of Matthias Scheler) shows,
  17.  * that there is a FileHandle build up just like in ACTION_FINDXXX.
  18.  * But this FileHandle is not used, instead the original pointer
  19.  * from the transmitted packet is used, which does not contain
  20.  * usable data. So this patch only puts the address of the prepared
  21.  * FileHandle into the right place.
  22.  *
  23.  * usage: EPatsch.rexx SYS:Envoy/Services/filesystem.service
  24.  *                     (or where your filesystem.service is located)
  25.  *
  26.  * !!! PLEASE make a backup of your filesystem.service !!!
  27.  */
  28.  
  29. pw.0=7
  30. pw.1='261B 260D'
  31. pw.2='281B E483'
  32. pw.3='2A1B 2543'
  33. pw.4='2C2A 0014'
  34. pw.5='0020 261B'
  35. pw.6='2E2A 281B'
  36. pw.7='0024 2A1B'
  37.  
  38. offset11=14410
  39. offset12=14418
  40.  
  41. qt=d2c(34)
  42.  
  43. Options Results
  44. Address Command
  45.  
  46. Parse ARG fs
  47. offset=0
  48.  
  49. if ( fs='' ) then do
  50.   say "in which drawer is your Envoy-Installation located?"
  51.   pull envoy
  52.   if ( right(envoy,1)~=':'  ) then
  53.     envoy=envoy'/'
  54.   fs=envoy'Services/filesystem.service'
  55. end
  56.  
  57. if ( open(fsh,fs,'A')~=0 ) then do
  58.   Call Seek(fsh,90,'B')
  59.   str=ReadCH(fsh,25)
  60.   if ( Left(str,23)='$VER: fs 40.11 (6.9.93)' ) then
  61.     offset=offset11
  62.   else if ( Left(str,25)='$VER: fs 40.12 (19.10.93)' ) then
  63.     offset=offset12
  64.  
  65.   if ( offset~=0 ) then do
  66.     Call Seek(fsh,offset,'B')
  67.     str=ReadCH(fsh,pw.0*2)
  68.     do k=1 for pw.0
  69.       if ( substr(str,k*2-1,2)~=d2c(x2d(left(pw.k,4)),2) ) then do
  70.         do k=1 for pw.0
  71.           if ( substr(str,k*2-1,2)~=d2c(x2d(right(pw.k,4)),2) ) then do
  72.             say "binary differs from expected code - aborting"
  73.             say "offset $"d2x(offset)"  expected: $"left(pw.k,4)"  actual: $"d2x(c2d(substr(str,k*2-1,2)),4)
  74.             exit(10)
  75.           end
  76.           say qt||fs||qt" is already patched"
  77.           exit(5)
  78.         end
  79.       end
  80.     end
  81.     if ( Seek(fsh,offset,'B')=offset ) then do
  82.       str=''
  83.       do k=1 for pw.0
  84.         str=str||d2c(x2d(right(pw.k,4)),2)
  85.       end
  86.       if ( WriteCH(fsh,str)=pw.0*2 ) then do
  87.         say "sucessfully patched "qt||fs||qt
  88.       end; else do
  89.         say "could not write to "qt||fs||qt" - file may be left damaged"
  90.         exit(20)
  91.       end
  92.     end; else do
  93.       say "could not seek to patch position"
  94.       exit(10)
  95.     end
  96.   end; else do
  97.     say "this is not the right Version fs 40.11 (6.9.93) or fs 40.12 (19.10.93)"
  98.     say "of "qt||fs||qt
  99.     exit(10)
  100.   end
  101. end; else do
  102.   say "cannot open "qt||fs||qt
  103.   exit(10)
  104. end
  105.  
  106. /* my next patch will be written in installer 8-) */
  107.